package org.kazuhiko.rpg.client.net.packet;

import java.util.Map;

public class Packet
{
	private final PacketDefinition definition;
	
	private final Map<String, Object> fields;
	
	public Packet( PacketDefinition definition, Map<String, Object> fields )
	{
		this.definition = definition;
		this.fields = fields;
	}
	
	public PacketDefinition getDefinition()
	{
		return definition;
	}
	
	public Number getNumericField( String fieldName )
	{
		return ( Number ) fields.get( fieldName );
	}
	
	public String getStringField( String fieldName )
	{
		return ( String ) fields.get( fieldName );
	}
	
	public byte[] getByteArrayField( String fieldName )
	{
		return ( byte[] ) fields.get( fieldName );
	}
	
	@Override
	public String toString()
	{
		return definition.getName();
	}
}